import redis
import time

from settings import HOST,  PWD, PORT, DB


def connect_redis():
    global db_cn
    host = HOST
    pwd = PWD
    port = PORT
    db = DB
    try:
        db_cn = redis.Redis(host=host, port=port, db=db, decode_responses=True, password=pwd)
    except Exception as e:
        print(e)
    return db_cn


def get_redis_size():
    COMPANY_NAME = 'WeiJianWei'
    redis_db = connect_redis()
    count = redis_db.scard(COMPANY_NAME)
    print('redis db 15 has {} jobs left'.format(count))


if __name__ == '__main__':
    while 1:
        get_redis_size()
        time.sleep(3)

